package FunctiiTrigo;
import Functii.Functie;
import Operatori.Produs;


public final class Cos extends Functie {
	public static double calcul(double a){
		return Math.cos(a);
	}
	
	public double calcul(){
		if(fStang==null)
			System.exit(1);
		return calcul(fStang.calcul());
	}
	
	public String derivare(){
		if(fStang==null)
			System.exit(1);
		return Produs.concatTermens(fStang.derivare(), Sin.concatTermeni(fStang.toString()));
	}
	
	public double calculDerivata(){
		if(fStang==null)
			System.exit(1);
		return Produs.Calcul(fStang.calculDerivata(),-Sin.calcul(fStang.calcul()));
	}
	
	public String toString(){
		if(fStang==null)
			System.exit(1);
		return concatTermeni(fStang.toString());
	}
	
	public static String concatTermeni(String a){
		String aux;
		int nrP;
		
		nrP=a.charAt(0)=='(' ? 0:2;
		
		aux="cos";
		if(nrP!=0) 
			aux+="(";
		aux+=a;
		if(nrP!=0)
			aux+=")";
		return aux;
	}

}
